#include "dtype.h"
#include "din.h"
#include "weight.h"
#include "bias.h"

#include <stdio.h>

#define CONV_OUT_CHANNEL    6
#define CONV_IN_CHANNEL     1
#define DIN_SIZE            32
#define DOUT_SIZE           28
#define KER_SIZE            5

dtype dout_c[CONV_OUT_CHANNEL][DOUT_SIZE][DOUT_SIZE]={0.0f};


void conv2d_ic1s32_ko6i1s5_oc6s28(
    dtype din[CONV_IN_CHANNEL][DIN_SIZE][DIN_SIZE],
    dtype ker[CONV_OUT_CHANNEL][CONV_IN_CHANNEL][KER_SIZE][KER_SIZE],
    dtype bias[CONV_OUT_CHANNEL],
    dtype dout[CONV_OUT_CHANNEL][DOUT_SIZE][DOUT_SIZE]
){
    for (int i = 0; i < DOUT_SIZE; i++){
        for (int j = 0; j < DOUT_SIZE; j++){
            dout[0][i][j] = bias[0];
            for (int k_i = 0; k_i < KER_SIZE; k_i++){
                for (int k_j = 0; k_j < KER_SIZE; k_j++){
                    dout[0][i][j] += 
                        (din[0][i+k_i][j+k_j] *
                        // ker[0][0][KER_SIZE-1-k_i][KER_SIZE-1-k_j]);
                        ker[0][0][k_i][k_j]);
                }
            }
        }
    }   
}

int main(int argc, char const *argv[])
{
    conv2d_ic1s32_ko6i1s5_oc6s28(
        (dtype (*)[DIN_SIZE][DIN_SIZE])din[0],
        (dtype (*)[CONV_IN_CHANNEL][KER_SIZE][KER_SIZE])weight, 
        (dtype *)bias, 
        dout_c);
    printf("%f", dout_c[0][0][0]);
    return 0;
}
